package com.ymttest.database.sqlwapper.godfreight;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.freight_template;
import com.ymttest.utils.AgentUsers;

public class freight_templateWapper {
	SqlManager manager;

    public freight_templateWapper() {
        manager = new SqlManager("mysqlgodfreightsit1");
    }

    public freight_template selectByPrimaryKey(Integer templateId) {
    	//freight_template model=new freight_template();
        List<freight_template> freight_template = manager.
                getSelectResults("com.ymttest.database.mapping.godfreight.freight_templateMapper.selectByPrimaryKey",templateId);
        manager.commit();
        if(freight_template.size()>0)
          return freight_template.get(0);
		return null;
    }

    public void updateStatusByKey(Integer templateId) {
       manager.update("com.ymttest.database.mapping.godfreight.freight_templateMapper.updateStatusByKey",templateId);
        manager.commit();
    }

    public Integer selectCountBySellerId(int sellerId,boolean isNormalCount){
        Map m = new HashMap<>();
        m.put("sellerId",sellerId);
        if (isNormalCount){
            m.put("isNormalCount",1);
        }
        List<Integer> selectResults = manager.getSelectResults(
                "com.ymttest.database.mapping.godfreight.freight_templateMapper.selectCountBySellerId", m);
        return selectResults.get(0);
    }

    public int deleteBySellerId(Integer sellerId) {
    	
        int count=manager.delete("com.ymttest.database.mapping.godfreight.freight_templateMapper.deleteBySellerId",sellerId);
        manager.commit();
        return count;
        
     }
    
    public static void main(String[] args) {
        freight_templateWapper freight_templateWapper = new freight_templateWapper();
        System.out.println(freight_templateWapper.selectCountBySellerId(AgentUsers.rootUserId,false));
    }
}
